<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Factura extends CI_Controller {

    public function __construct() {
        parent::__construct();
        session_start();
        $this->estaLogueado();
        $this->verificarPermiso();
        $this->establecimiento = $_SESSION["establecimiento"]["id_establecimiento"];
        $this->load->model('reservam');
        $this->load->model('establecimientom');
        $this->load->model('paism');
        $this->load->model('ajustem');
        $this->load->model('venta_producto_serviciom');
        $this->load->model('tarifa_x_diam');
        $this->load->model('ingreso_reservam');
        $this->validarReserva();
    }

    public function index() {
        $data = array();
        $this->loadData($data);
        $this->load->view('facturaV', $data);
    }

    public function loadData(&$data) {

        $departamentos = array("5002" => "Abejorral",
            "54003" => "Abrego",
            "5004" => "Abriaquí",
            "50006" => "Acacias",
            "27006" => "Acandí",
            "41006" => "Acevedo",
            "13006" => "Achí",
            "41013" => "Agrado",
            "25001" => "Agua de dios",
            "20011" => "Aguachica",
            "68013" => "Aguada",
            "17013" => "Aguadas",
            "85010" => "Aguazul",
            "20013" => "Agustín codazzi",
            "41016" => "Aipe",
            "18029" => "Albania",
            "44030" => "Albania",
            "68020" => "Albania",
            "25019" => "Albán",
            "52019" => "Albán",
            "76020" => "Alcalá",
            "52022" => "Aldana",
            "5021" => "Alejandría",
            "47030" => "Algarrobo",
            "41020" => "Algeciras",
            "19022" => "Almaguer",
            "15022" => "Almeida",
            "73024" => "Alpujarra",
            "41026" => "Altamira",
            "27025" => "Alto baudó",
            "13030" => "Altos del rosario",
            "73026" => "Alvarado",
            "5030" => "Amagá",
            "5031" => "Amalfi",
            "73030" => "Ambalema",
            "48" => "Aname",
            "25035" => "Anapoima",
            "52036" => "Ancuyá",
            "76036" => "Andalucía",
            "5034" => "Andes",
            "5036" => "Angelópolis",
            "5038" => "Angostura",
            "25040" => "Anolaima",
            "5040" => "Anorí",
            "17042" => "Anserma",
            "76041" => "Ansermanuevo",
            "5130" => "Antioquia",
            "5044" => "Anza",
            "73043" => "Anzoategui",
            "5045" => "Apartadó",
            "66045" => "Apia",
            "116" => "Apulo",
            "15047" => "Aquitania",
            "47053" => "Aracataca",
            "17050" => "Aranzazu",
            "68051" => "Aratoca",
            "81001" => "Arauca",
            "81065" => "Arauquita",
            "25053" => "Arbeláez",
            "52051" => "Arboleda",
            "54051" => "Arboledas",
            "5051" => "Arboletes",
            "15051" => "Arcabuco",
            "13042" => "Arenal",
            "19050" => "Argelia",
            "5055" => "Argelia",
            "76054" => "Argelia",
            "47058" => "Ariguaní",
            "13052" => "Arjona",
            "5059" => "Armenia",
            "63001" => "Armenia",
            "73055" => "Armero",
            "20032" => "Astrea",
            "73067" => "Ataco",
            "23068" => "Ayapel",
            "27073" => "Bagadó",
            "27075" => "Bahía solano",
            "27077" => "Bajo baudó",
            "19075" => "Balboa",
            "66075" => "Balboa",
            "8078" => "Baranoa",
            "41078" => "Baraya",
            "52079" => "Barbacoas",
            "5079" => "Barbosa",
            "68077" => "Barbosa",
            "68079" => "Barichara",
            "50110" => "Barranca de upia",
            "68081" => "Barrancabermeja",
            "44078" => "Barrancas",
            "13074" => "Barranco de loba",
            "94343" => "Barranco mina",
            "8001" => "Barranquilla",
            "20045" => "Becerril",
            "17088" => "Belalcázar",
            "5088" => "Bello",
            "5086" => "Belmira",
            "25086" => "Beltrán",
            "15087" => "Belén",
            "52083" => "Belén",
            "27090" => "Belén de bajira",
            "18094" => "Belén de los andaquies",
            "66088" => "Belén de umbria",
            "15090" => "Berbeo",
            "5091" => "Betania",
            "15092" => "Beteitiva",
            "5093" => "Betulia",
            "68092" => "Betulia",
            "25095" => "Bituima",
            "15097" => "Boavita",
            "54099" => "Bochalema",
            "11001" => "Bogotá d. c.",
            "25099" => "Bojacá",
            "27099" => "Bojayá",
            "126" => "Bolivar",
            "17879" => "Bolivia",
            "19100" => "Bolívar",
            "68101" => "Bolívar",
            "76100" => "Bolívar",
            "20060" => "Bosconia",
            "15104" => "Boyacá",
            "15106" => "Briceño",
            "5107" => "Briceño",
            "68001" => "Bucaramanga",
            "54109" => "Bucarasica",
            "76109" => "Buenaventura",
            "15109" => "Buenavista",
            "23079" => "Buenavista",
            "63111" => "Buenavista",
            "70110" => "Buenavista",
            "19110" => "Buenos aires",
            "52110" => "Buesaco",
            "76111" => "Buga",
            "76113" => "Bugalagrande",
            "5113" => "Buriticá",
            "15114" => "Busbanza",
            "70025" => "C",
            "25120" => "Cabrera",
            "68121" => "Cabrera",
            "50124" => "Cabuyaro",
            "94886" => "Cacahual",
            "25123" => "Cachipay",
            "5125" => "Caicedo",
            "76122" => "Caicedonia",
            "70124" => "Caimito",
            "73124" => "Cajamarca",
            "19130" => "Cajibío",
            "25126" => "Cajicá",
            "13140" => "Calamar",
            "95015" => "Calamar",
            "63130" => "Calarcá",
            "15" => "Caldas",
            "15131" => "Caldas",
            "5129" => "Caldas",
            "19137" => "Caldono",
            "76001" => "Cali",
            "68132" => "California",
            "76126" => "Calima",
            "19142" => "Caloto",
            "5134" => "Campamento",
            "8137" => "Campo de la cruz",
            "41132" => "Campoalegre",
            "15135" => "Campohermoso",
            "23090" => "Canalete",
            "76130" => "Candelaria",
            "8141" => "Candelaria",
            "13160" => "Cantagallo",
            "25148" => "Caparrapí",
            "68147" => "Capitanejo",
            "25151" => "Caqueza",
            "5142" => "Caracolí",
            "5145" => "Caramanta",
            "68152" => "Carcasi",
            "5147" => "Carepa",
            "73148" => "Carmen apicalá",
            "25154" => "Carmen de carupa",
            "5148" => "Carmen de viboral",
            "27120" => "Carmen del darién",
            "5150" => "Carolina",
            "13001" => "Cartagena de indias",
            "18150" => "Cartagena del chairá",
            "76147" => "Cartago",
            "97161" => "Caruru",
            "73152" => "Casabianca",
            "50150" => "Castilla la nueva",
            "70" => "Catambuco",
            "5154" => "Caucasia",
            "5138" => "Cañasgordas",
            "43" => "Ceilan",
            "68160" => "Cepitá",
            "23162" => "Cereté",
            "15162" => "Cerinza",
            "68162" => "Cerrito",
            "47161" => "Cerro san antonio",
            "27150" => "Certegui",
            "52240" => "Chachag³í",
            "25168" => "Chaguaní",
            "70230" => "Chalán",
            "85015" => "Chameza",
            "73168" => "Chaparral",
            "68167" => "Charalá",
            "68169" => "Charta",
            "49" => "Chicoral",
            "5172" => "Chigorodo",
            "20175" => "Chimichagua",
            "23168" => "Chimá",
            "68176" => "Chimá",
            "15172" => "Chinavita",
            "17174" => "Chinchiná",
            "23182" => "Chin·",
            "54172" => "Chinácota",
            "25178" => "Chipaque",
            "68179" => "Chipatá",
            "15176" => "Chiquinquirá",
            "15232" => "Chiquiza",
            "20178" => "Chiriguaná",
            "15180" => "Chiscas",
            "15183" => "Chita",
            "54174" => "Chitagá",
            "15185" => "Chitaraque",
            "15187" => "Chivatá",
            "47170" => "Chivolo",
            "15236" => "Chivor",
            "25181" => "Choachí",
            "25183" => "Chocontá",
            "25175" => "Chía",
            "13188" => "Cicuco",
            "47799" => "Cienaga de oro",
            "68190" => "Cimitarra",
            "63190" => "Circasia",
            "5190" => "Cisneros",
            "5101" => "Ciudad bolívar",
            "12001" => "Ciudad no existe qeq 12000",
            "47189" => "Ciénaga",
            "23189" => "Ciénaga de oro",
            "15189" => "Ciénega",
            "13222" => "Clemencia",
            "5197" => "Cocorna",
            "73200" => "Coello",
            "25200" => "Cogua",
            "41206" => "Colombia",
            "70204" => "Coloso",
            "52203" => "Colón",
            "86219" => "Colón",
            "126" => "Combita",
            "5206" => "Concepción",
            "68207" => "Concepción",
            "47200" => "Concordia",
            "5209" => "Concordia",
            "27205" => "Condoto",
            "68209" => "Confines",
            "52207" => "Consaca",
            "52210" => "Contadero",
            "68211" => "Contratación",
            "54206" => "Convención",
            "5212" => "Copacabana",
            "15212" => "Coper",
            "19212" => "Corinto",
            "68217" => "Coromoro",
            "70215" => "Corozal",
            "15215" => "Corrales",
            "25214" => "Cota",
            "15218" => "Covarachía",
            "70220" => "Coveñas",
            "73217" => "Coyaima",
            "81220" => "Cravo norte",
            "52224" => "Cuaspud",
            "30" => "Cubarral",
            "15223" => "Cubará",
            "15224" => "Cucaita",
            "25224" => "Cucunubá",
            "54001" => "Cucuta",
            "54223" => "Cucutilla",
            "15226" => "Cuitiva",
            "50226" => "Cumaral",
            "99773" => "Cumaribo",
            "52227" => "Cumbal",
            "52233" => "Cumbitara",
            "73226" => "Cunday",
            "68229" => "Curití",
            "18205" => "Currillo",
            "50128" => "Currulao",
            "20228" => "Curumaní",
            "5120" => "Cáceres",
            "54128" => "Cáchira",
            "54125" => "Cácota",
            "15204" => "Cómbita",
            "13212" => "Córdoba",
            "52215" => "Córdoba",
            "63212" => "Córdoba",
            "5234" => "Dabeiba",
            "76233" => "Dagua",
            "44090" => "Dibulla",
            "44098" => "Distracción",
            "73236" => "Dolores",
            "5237" => "Don matías",
            "66170" => "Dos quebradas",
            "15238" => "Duitama",
            "54239" => "Durania",
            "5240" => "Ebejico",
            "76243" => "El aguila",
            "5250" => "El bagre",
            "47245" => "El banco",
            "19960" => "El bordo",
            "76246" => "El cairo",
            "50245" => "El calvario",
            "27135" => "El cantón de san pablo",
            "54245" => "El carmen",
            "27245" => "El carmen de atrato",
            "13244" => "El carmen de bolívar",
            "68235" => "El carmen de chucuri",
            "50251" => "El castillo",
            "76248" => "El cerrito",
            "52250" => "El charco",
            "15244" => "El cocuy",
            "25245" => "El colegio",
            "20238" => "El copey",
            "47025" => "El dificil",
            "18247" => "El doncello",
            "50270" => "El dorado",
            "76250" => "El dovio",
            "91263" => "El encanto",
            "15248" => "El espino",
            "68271" => "El florián",
            "68245" => "El guacamayo",
            "13248" => "El guamo",
            "44110" => "El molino",
            "17028" => "El niagara armenia",
            "117" => "El ocaso",
            "20250" => "El paso",
            "18256" => "El paujíl",
            "13268" => "El peñón",
            "25258" => "El peñón",
            "68250" => "El peñón",
            "47258" => "El piñón",
            "68255" => "El playón",
            "95025" => "El retorno",
            "47268" => "El retén",
            "70232" => "El roble",
            "124" => "El rosal",
            "52256" => "El rosario",
            "51" => "El salado",
            "52258" => "El tablón",
            "19256" => "El tambo",
            "52260" => "El tambo",
            "54250" => "El tarra",
            "54261" => "El zulia",
            "41244" => "Elías",
            "68264" => "Encino",
            "68266" => "Enciso",
            "126" => "Engativá",
            "5264" => "Entrerrios",
            "5266" => "Envigado",
            "73268" => "Espinal",
            "25269" => "Facatativá",
            "73270" => "Falan",
            "17272" => "Filadelfia",
            "63272" => "Filandia",
            "15272" => "Firavitoba",
            "73275" => "Flandes",
            "18001" => "Florencia",
            "19290" => "Florencia",
            "15276" => "Floresta",
            "90" => "Florian",
            "76275" => "Florida",
            "68276" => "Floridablanca",
            "44279" => "Fonseca",
            "81300" => "Fortul",
            "25281" => "Fosca",
            "52520" => "Francisco pizarro",
            "5282" => "Fredonia",
            "73283" => "Fresno",
            "5284" => "Frontino",
            "50287" => "Fuente de oro",
            "47288" => "Fundación",
            "52287" => "Funes",
            "25286" => "Funza",
            "25290" => "Fusagasugá",
            "25288" => "F·quene",
            "25279" => "Fómeque",
            "25293" => "Gachalá",
            "25295" => "Gachancipá",
            "15293" => "Gachantivá",
            "25297" => "Gachetá",
            "8296" => "Galapa",
            "70235" => "Galeras",
            "68296" => "Galán",
            "25299" => "Gama",
            "20295" => "Gamarra",
            "68298" => "Gambita",
            "15299" => "Garagoa",
            "41298" => "Garzón",
            "41306" => "Gigante",
            "76306" => "Ginebra",
            "5306" => "Giraldo",
            "25307" => "Girardot",
            "5308" => "Girardota",
            "68307" => "Girón",
            "5310" => "Gomez plata",
            "20310" => "González",
            "54313" => "Gramalote",
            "25312" => "Granada",
            "50313" => "Granada",
            "5313" => "Granada",
            "31" => "Granada boca de monte",
            "68318" => "Guaca",
            "47033" => "Guacamayal",
            "15317" => "Guacamayas",
            "91" => "Guacamayo",
            "76318" => "Guacari",
            "52066" => "Guachavez",
            "19300" => "Guachené",
            "25317" => "Guachetá",
            "52317" => "Guachucal",
            "41319" => "Guadalupe",
            "5315" => "Guadalupe",
            "68320" => "Guadalupe",
            "25320" => "Guaduas",
            "52320" => "Guaitarilla",
            "52323" => "Gualmatán",
            "47318" => "Guamal",
            "50318" => "Guamal",
            "73319" => "Guamo",
            "19318" => "Guapi",
            "68322" => "Guapota",
            "70265" => "Guaranda",
            "5318" => "Guarne",
            "25322" => "Guasca",
            "45" => "Guataca",
            "5321" => "Guatape",
            "25324" => "Guataquí",
            "25326" => "Guatavita",
            "15322" => "Guateque",
            "66318" => "Guatica",
            "68324" => "Guavata",
            "52" => "Guayabal",
            "25328" => "Guayabal de síquima",
            "25335" => "Guayabetal",
            "15325" => "Guayatá",
            "124" => "Guepsa",
            "15332" => "Guicán",
            "25339" => "Gutiérrez",
            "68327" => "G³epsa",
            "15296" => "Gámeza",
            "63302" => "Génova",
            "54344" => "Hacarí",
            "13300" => "Hatillo de loba",
            "68344" => "Hato",
            "85125" => "Hato corozal",
            "44378" => "Hatonuevo",
            "52335" => "Hatonuevo",
            "5347" => "Heliconia",
            "54347" => "Herrán",
            "73347" => "Herveo",
            "5353" => "Hispania",
            "41349" => "Hobo",
            "73349" => "Honda",
            "73001" => "Ibagué",
            "73352" => "Icononzo",
            "52352" => "Iles",
            "52354" => "Imués",
            "19355" => "Inza",
            "94001" => "Inírida",
            "52356" => "Ipiales",
            "41357" => "Iquira",
            "41359" => "Isnos",
            "27361" => "Istmina",
            "5360" => "Itaguí",
            "5361" => "Ituango",
            "15362" => "Iza",
            "19364" => "Jambaló",
            "76364" => "Jamundí",
            "5364" => "Jardín",
            "15367" => "Jenesano",
            "15368" => "Jericó",
            "5368" => "Jericó",
            "25368" => "Jerusalén",
            "68368" => "Jesus maría",
            "68370" => "Jordán",
            "8372" => "Juan de acosta",
            "25372" => "Junín",
            "27372" => "Juradó",
            "23300" => "La apartada",
            "41378" => "La argentina",
            "68377" => "La belleza",
            "25377" => "La calera",
            "15380" => "La capilla",
            "5376" => "La ceja",
            "66383" => "La celia",
            "91405" => "La chorrera",
            "23315" => "La cotorra",
            "52378" => "La cruz",
            "76377" => "La cumbre",
            "54041" => "La don juana",
            "17380" => "La dorada",
            "86757" => "La dorada",
            "54385" => "La esperanza",
            "5380" => "La estrella",
            "52381" => "La florida",
            "20383" => "La gloria",
            "93" => "La granja",
            "94885" => "La guadalupe",
            "86322" => "La hormiga",
            "20400" => "La jagua de ibirico",
            "44400" => "La jagua del pilar",
            "26" => "La llana",
            "52385" => "La llanada",
            "50350" => "La macarena",
            "17388" => "La merced",
            "25386" => "La mesa",
            "18410" => "La montañita",
            "25394" => "La palma",
            "20621" => "La paz",
            "68397" => "La paz",
            "91407" => "La pedrera",
            "25398" => "La peña",
            "41396" => "La plata",
            "54398" => "La playa",
            "99524" => "La primavera",
            "85136" => "La salina",
            "19392" => "La sierra",
            "86250" => "La tagua",
            "63401" => "La tebaida",
            "52390" => "La tola",
            "52399" => "La unión",
            "5400" => "La unión",
            "70400" => "La unión",
            "76400" => "La unión",
            "50370" => "La uribe",
            "15403" => "La uvita",
            "19397" => "La vega",
            "25402" => "La vega",
            "15401" => "La victoria",
            "76403" => "La victoria",
            "66400" => "La virginia",
            "54377" => "Labateca",
            "15377" => "Labranzagrande",
            "68385" => "Landazuri",
            "50" => "Laureles",
            "68406" => "Lebrija",
            "52405" => "Leiva",
            "50400" => "Lejanías",
            "25407" => "Lenguazaque",
            "73408" => "Lerida",
            "91001" => "Leticia",
            "73411" => "Libano",
            "5411" => "Liborina",
            "52411" => "Linares",
            "27250" => "Litoral del bajo san juan",
            "27413" => "Lloró",
            "23417" => "Lorica",
            "52418" => "Los andes",
            "23419" => "Los córdobas",
            "70418" => "Los palmitos",
            "54405" => "Los patios",
            "68418" => "Los santos",
            "54418" => "Lourdes",
            "8421" => "Luruaco",
            "19418" => "López",
            "15425" => "Macanal",
            "68425" => "Macaravita",
            "5425" => "Maceo",
            "25426" => "Machetá",
            "25430" => "Madrid",
            "13430" => "Magangué",
            "52427" => "Maguí",
            "13433" => "Mahates",
            "44430" => "Maicao",
            "70429" => "Majagual",
            "47" => "Malagana",
            "8433" => "Malambo",
            "52435" => "Mallama",
            "8436" => "Manatí",
            "20443" => "Manaure",
            "44560" => "Manaure",
            "17001" => "Manizales",
            "25436" => "Manta",
            "17433" => "Manzanares",
            "85139" => "Maní",
            "50325" => "Mapiripán",
            "13440" => "Margarita",
            "5440" => "Marinilla",
            "15442" => "Maripí",
            "73443" => "Mariquita",
            "17442" => "Marmato",
            "17444" => "Marquetalia",
            "66440" => "Marsella",
            "17446" => "Marulanda",
            "13442" => "María la baja",
            "68444" => "Matanza",
            "5001" => "Medellín",
            "50632" => "Medellín del ariari",
            "25438" => "Medina",
            "27415" => "Medio atrato",
            "27420" => "Medio baudó",
            "27450" => "Medio san juan",
            "73449" => "Melgar",
            "19450" => "Mercaderes",
            "50330" => "Mesetas",
            "18460" => "Milán",
            "15455" => "Miraflores",
            "95200" => "Miraflores",
            "19455" => "Miranda",
            "91460" => "Mirití-paranáá",
            "66456" => "Mistrato",
            "97001" => "Mit·",
            "86001" => "Mocoa",
            "68464" => "Mogotes",
            "68468" => "Molagavita",
            "23464" => "Momil",
            "13468" => "Mompós",
            "15464" => "Mongua",
            "15466" => "Monguí",
            "15469" => "Moniquirá",
            "5467" => "Montebello",
            "13458" => "Montecristo",
            "23466" => "Montelibano",
            "63470" => "Montenegro",
            "85162" => "Monterrey",
            "23001" => "Montería",
            "13473" => "Morales",
            "19473" => "Morales",
            "18479" => "Morelia",
            "94888" => "Morichal nuevo",
            "70473" => "Morroa",
            "25473" => "Mosquera",
            "52473" => "Mosquera",
            "15476" => "Motavita",
            "23500" => "Moñitos",
            "73461" => "Murillo",
            "5475" => "Murindo",
            "5480" => "Mutata",
            "54480" => "Mutiscua",
            "15480" => "Muzo",
            "68432" => "Málaga",
            "39" => "Naranjal",
            "25483" => "Nariño",
            "52485" => "Nariño",
            "5483" => "Nariño",
            "41483" => "Nataga",
            "73483" => "Natagaima",
            "122" => "Nazareth",
            "5495" => "Nechí",
            "5490" => "Necoclí",
            "17486" => "Neira",
            "41001" => "Neiva",
            "25486" => "Nemocón",
            "25488" => "Nilo",
            "25489" => "Nimaima",
            "15491" => "Nobsa",
            "25491" => "Nocaima",
            "26" => "Norcasia",
            "27491" => "Novita",
            "47390" => "Nueva granada",
            "15494" => "Nuevo colón",
            "85225" => "Nunchía",
            "27495" => "Nuquí",
            "76497" => "Obando",
            "68498" => "Ocamonte",
            "54498" => "Ocaña",
            "68500" => "Oiba",
            "15500" => "Oicata",
            "5501" => "Olaya",
            "52490" => "Olaya herrera",
            "68502" => "Onzaga",
            "41503" => "Oporapa",
            "86320" => "Orito",
            "85230" => "Orocué",
            "73504" => "Ortega",
            "52506" => "Ospina",
            "25506" => "Ospina pérez",
            "15507" => "Otanche",
            "70508" => "Ovejas",
            "15511" => "Pachavita",
            "25513" => "Pacho",
            "97511" => "Pacoa",
            "17513" => "Pacora",
            "19513" => "Padilla",
            "41518" => "Paicol",
            "20517" => "Pailitas",
            "25518" => "Paime",
            "15516" => "Paipa",
            "15518" => "Pajarito",
            "41524" => "Palermo",
            "17524" => "Palestina",
            "41530" => "Palestina",
            "68522" => "Palmar",
            "8520" => "Palmar de varela",
            "68524" => "Palmas del socorro",
            "76520" => "Palmira",
            "70523" => "Palmito",
            "73520" => "Palocabildo",
            "54518" => "Pamplona",
            "54520" => "Pamplonita",
            "94887" => "Pana pana",
            "25524" => "Pandi",
            "15522" => "Panqueba",
            "97777" => "Papunahua",
            "68533" => "Paramo",
            "25530" => "Paratebueno",
            "25535" => "Pasca",
            "52001" => "Pasto",
            "19532" => "Patía",
            "15531" => "Pauna",
            "15533" => "Paya",
            "64" => "Payan",
            "85250" => "Paz de ariporo",
            "15537" => "Paz de río",
            "47541" => "Pedraza",
            "20550" => "Pelaya",
            "17541" => "Pensilvania",
            "5543" => "Peque",
            "66001" => "Pereira",
            "15542" => "Pesca",
            "5541" => "Peñol",
            "19533" => "Piamonte",
            "68547" => "Piedecuesta",
            "73547" => "Piedras",
            "19548" => "Piendamó",
            "63548" => "Pijao",
            "47545" => "Pijiño del carmen",
            "68549" => "Pinchote",
            "13549" => "Pinillos",
            "8549" => "Piojo",
            "15550" => "Pisba",
            "41548" => "Pital",
            "41551" => "Pitalito",
            "47551" => "Pivijay",
            "73555" => "Planadas",
            "23555" => "Planeta rica",
            "47555" => "Plato",
            "52540" => "Policarpa",
            "8558" => "Polonuevo",
            "8560" => "Ponedera",
            "19001" => "Popayán",
            "85263" => "Pore",
            "52560" => "Potosí",
            "25" => "Potrerillo",
            "76563" => "Pradera",
            "73563" => "Prado",
            "52565" => "Providencia",
            "88564" => "Providencia",
            "123" => "Pto.bogota",
            "20575" => "Pueblo bello",
            "23570" => "Pueblo nuevo",
            "66572" => "Pueblo rico",
            "5576" => "Pueblorrico",
            "47570" => "Puebloviejo",
            "68572" => "Puente nacional",
            "52573" => "Puerres",
            "86568" => "Puerto asis",
            "5579" => "Puerto berrio",
            "15572" => "Puerto boyacá",
            "86569" => "Puerto caicedo",
            "99001" => "Puerto carreño",
            "8573" => "Puerto colombia",
            "94884" => "Puerto colombia",
            "50450" => "Puerto concordia",
            "23574" => "Puerto escondido",
            "50568" => "Puerto gaitán",
            "86571" => "Puerto guzmán",
            "86573" => "Puerto leguízamo",
            "23580" => "Puerto libertador",
            "50577" => "Puerto lleras",
            "50573" => "Puerto lópez",
            "5585" => "Puerto nare",
            "91540" => "Puerto nariño",
            "68573" => "Puerto parra",
            "92" => "Puerto parra",
            "125" => "Puerto perales",
            "18592" => "Puerto rico",
            "50590" => "Puerto rico",
            "81591" => "Puerto rondón",
            "25572" => "Puerto salgar",
            "54553" => "Puerto santander",
            "91669" => "Puerto santander",
            "19573" => "Puerto tejada",
            "5591" => "Puerto triunfo",
            "68575" => "Puerto wilches",
            "25580" => "Pulí",
            "52585" => "Pupiales",
            "19585" => "Puracé",
            "73585" => "Purificación",
            "23586" => "Purísima",
            "15514" => "Páez",
            "19517" => "Páez",
            "25592" => "Quebradanegra",
            "25594" => "Quetame",
            "27001" => "Quibdó",
            "63594" => "Quimbaya",
            "66594" => "Quinchía",
            "25596" => "Quipile",
            "89" => "Quipile",
            "15580" => "Quípama",
            "25599" => "Rafael reyes",
            "54599" => "Ragonvalia",
            "15599" => "Ramiriquí",
            "85279" => "Recetor",
            "13580" => "Regidor",
            "5604" => "Remedios",
            "47605" => "Remolino",
            "8606" => "Repelón",
            "50606" => "Restrepo",
            "76606" => "Restrepo",
            "5607" => "Retiro",
            "25612" => "Ricaurte",
            "52612" => "Ricaurte",
            "27550" => "Rio iro",
            "27595" => "Rio quito",
            "73616" => "Rioblanco",
            "76616" => "Riofrío",
            "44001" => "Riohacha",
            "5615" => "Rionegro",
            "68615" => "Rionegro",
            "17614" => "Riosucio",
            "27615" => "Riosucio",
            "17616" => "Risaralda",
            "41615" => "Rivera",
            "52621" => "Roberto payán",
            "20027" => "Robles",
            "63" => "Robles",
            "76622" => "Roldanillo",
            "73622" => "Roncesvalles",
            "15621" => "Rondón",
            "19622" => "Rosas",
            "73624" => "Rovira",
            "15600" => "Ráquira",
            "20614" => "Río de oro",
            "13600" => "Río viejo",
            "68655" => "Sabana de torres",
            "8634" => "Sabanagrande",
            "5628" => "Sabanalarga",
            "85300" => "Sabanalarga",
            "8638" => "Sabanalarga",
            "47620" => "Sabanas de san angel",
            "5631" => "Sabaneta",
            "15632" => "Saboyá",
            "23660" => "Sahag·n",
            "41660" => "Saladoblanco",
            "17653" => "Salamina",
            "47675" => "Salamina",
            "54660" => "Salazar",
            "73671" => "Saldaña",
            "63690" => "Salento",
            "5642" => "Salgar",
            "15646" => "Samacá",
            "52678" => "Samaniego",
            "17662" => "Samaná",
            "17881" => "Samaria",
            "70670" => "Sampués",
            "41668" => "San agustín",
            "20710" => "San alberto",
            "5647" => "San andres",
            "68669" => "San andres",
            "88001" => "San andrés",
            "94" => "San andrés",
            "23670" => "San andrés de sotavento",
            "23672" => "San antero",
            "73675" => "San antonio",
            "25645" => "San antonio de tena",
            "119" => "San antonio del tequendama",
            "68673" => "San benito",
            "70678" => "San benito abad",
            "25649" => "San bernardo",
            "52685" => "San bernardo",
            "23675" => "San bernardo del viento",
            "54670" => "San calixto",
            "23678" => "San carlos",
            "5649" => "San carlos",
            "50680" => "San carlos guaroa",
            "25653" => "San cayetano",
            "54673" => "San cayetano",
            "127" => "San cristibal",
            "13620" => "San cristóbal",
            "20750" => "San diego",
            "15660" => "San eduardo",
            "13647" => "San estanislao",
            "94883" => "San felipe",
            "13650" => "San fernando",
            "25658" => "San francisco",
            "5652" => "San francisco",
            "86755" => "San francisco",
            "17880" => "San félix",
            "68679" => "San gil",
            "13654" => "San jacinto",
            "5656" => "San jerónimo",
            "68682" => "San joaquín",
            "15125" => "San jose de pare",
            "17690" => "San josé",
            "18610" => "San josé de la fragua",
            "5658" => "San josé de la montaña",
            "68684" => "San josé de miranda",
            "99760" => "San josé de ocune",
            "15664" => "San josé de pare",
            "95001" => "San josé del guaviare",
            "27660" => "San josé del palmar",
            "70702" => "San juan betulia",
            "50683" => "San juan de arama",
            "46" => "San juan de nepo",
            "5265" => "San juan de pasto",
            "25662" => "San juan de rioseco",
            "5659" => "San juan de urabá",
            "44650" => "San juan del cesar",
            "13657" => "San juan nepomuceno",
            "50686" => "San juanito",
            "52687" => "San lorenzo",
            "38" => "San luis",
            "5660" => "San luis",
            "73678" => "San luis",
            "50223" => "San luis de cubarral",
            "15667" => "San luis de gaceno",
            "85325" => "San luis de palenque",
            "70708" => "San marcos",
            "20770" => "San martín",
            "50689" => "San martín",
            "13667" => "San martín de loba",
            "15673" => "San mateo",
            "68686" => "San miguel",
            "86321" => "San miguel",
            "15676" => "San miguel de sema",
            "70713" => "San onofre",
            "13670" => "San pablo",
            "52693" => "San pablo",
            "15681" => "San pablo borbur",
            "5664" => "San pedro",
            "70717" => "San pedro",
            "76670" => "San pedro",
            "52694" => "San pedro de cartago",
            "5665" => "San pedro de uraba",
            "23686" => "San pelayo",
            "5667" => "San rafael",
            "5670" => "San roque",
            "19693" => "San sebastián",
            "47692" => "San sebastián de buenavista",
            "5674" => "San vicente",
            "68689" => "San vicente de chucurí",
            "18753" => "San vicente del cag³an",
            "47703" => "San zenón",
            "52683" => "Sandoná",
            "47707" => "Santa ana",
            "86015" => "Santa ana",
            "52696" => "Santa bárbara",
            "5679" => "Santa bárbara",
            "68705" => "Santa bárbara",
            "47715" => "Santa bárbara de pinto",
            "13673" => "Santa catalina",
            "68720" => "Santa helena del opón",
            "73686" => "Santa isabel",
            "8675" => "Santa lucía",
            "47001" => "Santa marta",
            "15690" => "Santa maría",
            "41676" => "Santa maría",
            "99572" => "Santa rita",
            "13683" => "Santa rosa",
            "19701" => "Santa rosa",
            "66682" => "Santa rosa de cabal",
            "15693" => "Santa rosa de viterbo",
            "13688" => "Santa rosa del sur",
            "99624" => "Santa rosalia",
            "15696" => "Santa sofía",
            "5686" => "Santa.rosa de osos",
            "52699" => "Santacruz",
            "5042" => "Santafe de antioquia",
            "15686" => "Santana",
            "19698" => "Santander de quilichao",
            "121" => "Santandersito",
            "54680" => "Santiago",
            "86760" => "Santiago",
            "5690" => "Santo domingo",
            "8685" => "Santo tomás",
            "5697" => "Santuario",
            "66687" => "Santuario",
            "52720" => "Sapuyés",
            "81736" => "Saravena",
            "54720" => "Sardinata",
            "25718" => "Sasaima",
            "15720" => "Sativanorte",
            "15723" => "Sativasur",
            "5736" => "Segovia",
            "25736" => "Sesquilé",
            "76736" => "Sevilla",
            "15740" => "Siachoque",
            "25740" => "Sibaté",
            "86749" => "Sibundoy",
            "54743" => "Silos",
            "25743" => "Silvania",
            "19743" => "Silvia",
            "68745" => "Simacota",
            "25745" => "Simijaca",
            "13744" => "Simití",
            "70742" => "Since",
            "70001" => "Sincelejo",
            "27745" => "Sipí",
            "47745" => "Sitionuevo",
            "25754" => "Soacha",
            "15753" => "Soatá",
            "15757" => "Socha",
            "68755" => "Socorro",
            "15755" => "Socota",
            "15759" => "Sogamoso",
            "18756" => "Solano",
            "8758" => "Soledad",
            "18785" => "Solita",
            "15761" => "Somondoco",
            "5756" => "Sonsón",
            "5761" => "Sopetrán",
            "13760" => "Soplaviento",
            "25758" => "Sopó",
            "15762" => "Sora",
            "15764" => "Soracá",
            "15763" => "Sotaquirá",
            "19760" => "Sotará",
            "68770" => "Suaita",
            "41770" => "Suaza",
            "25769" => "Subachoque",
            "19790" => "Sucre",
            "68773" => "Sucre",
            "70771" => "Sucre",
            "25772" => "Suesca",
            "25777" => "Supatá",
            "17777" => "Supia",
            "68780" => "Suratá",
            "25779" => "Susa",
            "15774" => "Susacón",
            "15776" => "Sutamarchán",
            "25781" => "Sutatausa",
            "15778" => "Sutatenza",
            "8770" => "Suán",
            "19780" => "Suárez",
            "73770" => "Suárez",
            "85315" => "Sácama",
            "15638" => "Sáchica",
            "25785" => "Tabio",
            "27787" => "Tadó",
            "13780" => "Talaigua nuevo",
            "20787" => "Tamalameque",
            "81794" => "Tame",
            "52786" => "Taminango",
            "52788" => "Tangua",
            "97666" => "Taraira",
            "91798" => "Tarapacáá",
            "5790" => "Tarazá",
            "27022" => "Tarido",
            "41791" => "Tarqui",
            "5792" => "Tarso",
            "15790" => "Tasco",
            "85410" => "Tauramena",
            "25793" => "Tausa",
            "41799" => "Tello",
            "25797" => "Tena",
            "47798" => "Tenerife",
            "25799" => "Tenjo",
            "15798" => "Tenza",
            "54800" => "Teorama",
            "41801" => "Teruel",
            "41797" => "Tesalia",
            "25805" => "Tibacuy",
            "15804" => "Tibaná",
            "15806" => "Tibasosa",
            "25807" => "Tibirita",
            "54810" => "Tib·",
            "73790" => "Tierradentro",
            "23807" => "Tierralta",
            "41807" => "Timaná",
            "19809" => "Timbiquí",
            "19807" => "Timbío",
            "15808" => "Tinjacá",
            "15810" => "Tipacoque",
            "13810" => "Tiquisio",
            "5809" => "Titiribí",
            "25783" => "Tobia",
            "15814" => "Toca",
            "25815" => "Tocaima",
            "25817" => "Tocancipá",
            "15816" => "Togui",
            "54820" => "Toledo",
            "5819" => "Toledo",
            "70823" => "Toluviejo",
            "70820" => "Tol·",
            "68820" => "Tona",
            "15820" => "Topaga",
            "25823" => "Topaipí",
            "19821" => "Toribío",
            "76823" => "Toro",
            "15822" => "Tota",
            "19824" => "Totoró",
            "17800" => "Tres esquinas",
            "85430" => "Trinidad",
            "76828" => "Trujillo",
            "8832" => "Tubará",
            "120" => "Tudela",
            "76834" => "Tuluá",
            "52835" => "Tumaco",
            "15001" => "Tunja",
            "15832" => "Tunungua",
            "52067" => "Tuque",
            "13836" => "Turbaco",
            "13838" => "Turbaná",
            "5837" => "Turbo",
            "15835" => "Turmequé",
            "15837" => "Tuta",
            "15839" => "Tutaza",
            "52838" => "T·querres",
            "85400" => "Támara",
            "5789" => "Támesis",
            "25839" => "Ubalá",
            "25841" => "Ubaque",
            "25843" => "Ubaté",
            "76845" => "Ulloa",
            "15842" => "Umbita",
            "25845" => "Une",
            "27800" => "Unguía",
            "27810" => "Unión panamericana",
            "5842" => "Uramita",
            "44847" => "Uribia",
            "5847" => "Urrao",
            "44855" => "Urumita",
            "8849" => "Usiacurí",
            "25900" => "Usme",
            "25851" => "Utica",
            "5854" => "Valdivia",
            "23855" => "Valencia",
            "73854" => "Valle de san juan",
            "86865" => "Valle del guamuéz",
            "68855" => "Valle san josé",
            "20001" => "Valledupar",
            "18860" => "Valparaíso",
            "5856" => "Valparaíso",
            "5858" => "Vegachí",
            "73861" => "Venadillo",
            "118" => "Venecia",
            "5861" => "Venecia",
            "15861" => "Ventaquemada",
            "25862" => "Vergara",
            "76863" => "Versalles",
            "68867" => "Vetas",
            "25867" => "Vianí",
            "17867" => "Victoria",
            "5873" => "Vigia del fuerte",
            "76869" => "Vijes",
            "54871" => "Villa caro",
            "15407" => "Villa de leyva",
            "54874" => "Villa del rosario",
            "19930" => "Villa rica",
            "86885" => "Villagarzón",
            "25871" => "Villagomez",
            "73870" => "Villahermosa",
            "17873" => "Villamaría",
            "13873" => "Villanueva",
            "44874" => "Villanueva",
            "68872" => "Villanueva",
            "85440" => "Villanueva",
            "25873" => "Villapinzón",
            "73873" => "Villarrica",
            "50001" => "Villavicencio",
            "41872" => "Villavieja",
            "25875" => "Villeta",
            "25878" => "Viotá",
            "15879" => "Viracacha",
            "50711" => "Vista hermosa",
            "17877" => "Viterbo",
            "68861" => "Vélez",
            "25885" => "Yacopí",
            "52885" => "Yacuanquer",
            "41885" => "Yaguará",
            "5885" => "Yali",
            "88" => "Yarima",
            "5887" => "Yarumal",
            "44" => "Yati",
            "97889" => "Yavarate",
            "5890" => "Yolombó",
            "5893" => "Yondó",
            "85001" => "Yopal",
            "76890" => "Yotoco",
            "76892" => "Yumbo",
            "13894" => "Zambrano",
            "68895" => "Zapatoca",
            "47510" => "Zapayán",
            "5895" => "Zaragoza",
            "76895" => "Zarzal",
            "15897" => "Zetaquirá",
            "25898" => "Zipacón",
            "25899" => "Zipaquirá",
            "47515" => "Zona bananera");
        $data["moneda"] = $_SESSION["establecimiento"]["moneda"];
        $data["datosHotel"] = $this->establecimientom->obtenerDatosBasicos($this->establecimiento);
        if ($data["datosHotel"][0]->id_pais == 169) {
            $data["datosHotel"][0]->ciudad = $departamentos[$data["datosHotel"][0]->ciudad];
        }

        $data["datosReserva"] = $this->reservam->detallesReserva($_GET["id"], $this->establecimiento);
        $data["datosReserva"][0]->nombre_pais = $this->paism->obtenerNombre($data["datosReserva"][0]->id_pais);
        if ($data["datosReserva"][0]->numero_factura == "") {
            $datosHoeteles = $this->establecimientom->obtenerDatos("ultimo_numero_factura", $_SESSION["establecimiento"]["id_establecimiento"]);
            $this->establecimientom->aumentarNumeroFactura();
            $numero_factura = $datosHoeteles[0]->ultimo_numero_factura;
            $numero_factura++;
            $this->reservam->setNumeroFactura($_GET["id"], $numero_factura);
            $data["datosReserva"][0]->numero_factura = $numero_factura;
        }
        $data["cantidad_noches"] = $this->diferenciaFechas($data['datosReserva'][0]->fecha_ingreso, $data['datosReserva'][0]->fecha_salida);
        $data["ajustesAlojamiento"] = $this->ajustem->obtenerSumaAjustesAlojamieno($_GET["id"]);
        $data["totalConsumos"] = $this->venta_producto_serviciom->obtenerTotalConsumos($_GET["id"]);
        $data["totalImpuestosConsumo"] = $this->venta_producto_serviciom->obtenerTotalImpuestosConsumos($_GET["id"]);

        $costoHospedajeSinImp = $this->tarifa_x_diam->obtenerCostosHospedaje($_GET["id"]);
        $data["totalConsumos"] = $this->venta_producto_serviciom->obtenerTotalConsumos($_GET["id"]);
        $data["totalImpuestosConsumo"] = $this->venta_producto_serviciom->obtenerTotalImpuestosConsumos($_GET["id"]);
        $data["ajustes"] = $this->ajustem->obtenerAjustes($_GET["id"]);
        $data["sumaTotalPagar"] = (float) ($data['datosReserva'][0]->impuesto + $costoHospedajeSinImp[0]->totalHospedaje + $data["totalConsumos"][0]->totalConsumos + $data["totalImpuestosConsumo"][0]->totalImpuestosConsumo + $data["ajustes"][0]->totalAjuste);
//    var_dump($data["datosReserva"]);

        $data["consumos"] = $this->venta_producto_serviciom->obtenerVentas($_GET["id"]);
        foreach ($data["consumos"] as $row) {
            $row->fecha = new DateTime($row->fecha);
            $row->fecha = $row->fecha->format('d/m/Y H:i:s');
        }



        $idReserva = $_GET["id"];
        $ingresos = $this->ingreso_reservam->obtenerIngresos($idReserva);
        $data["ingresos"] = $ingresos[0]->totalIngreso;
        $data["pendiente"] = $data["sumaTotalPagar"] - $data["ingresos"];
        if ($data["pendiente"] == 0) {
            $data["pendiente"] = "0";
        }

        $data["cuarto"] = $this->reservam->detallesBasicos($_GET["id"]);
        $data["logo"] = $this->establecimientom->obtenerDatos("logo", $this->establecimiento);
    }

    private function validarReserva() {
        $flag = false;
        if (!empty($_GET["id"])) {
            $r = $this->reservam->esMiReserva($_GET["id"], $_SESSION['establecimiento']['id_establecimiento']);
            if ($r[0]->cantidad != 1) {
                $flag = true;
            }
        } else {
            $flag = true;
        } if ($flag) {
            $_SESSION["mensaje"]["contenido"] = " La reserva no existe.";
            $_SESSION["mensaje"]["tipo"] = "advertencia";
            header("Location:calendario");
            exit();
        }
    }

    private function diferenciaFechas($desde, $hasta) {
        $datetime1 = date_create($desde);
        $datetime2 = date_create($hasta);
        $intervalo = date_diff($datetime1, $datetime2);
        return $intervalo->days;
    }

    private function verificarPermiso() {
        $this->load->model('permisom');
        $permisos = $this->permisom->obtenerPermisos($_SESSION["establecimiento"]["id_establecimiento"]);
        if (sizeof($permisos) == 0 || $permisos[0]->comprobantes == 0) {
            header("location: " . base_url() . "getservice?s=comprobantes");
            exit();
        }
    }

}
